package me.pearjelly.pmc.index.impl;

import java.util.List;

import me.pearjelly.pmc.index.Worker;
import me.pearjelly.pmc.service.SimpleService;
import me.pearjelly.pmc.util.Logger;

import org.apache.lucene.document.Document;

public class SimpleWorker implements Worker {
	@Override
	public void run() {
		log.info("Begin simple work...");
		long s = System.currentTimeMillis();
		List<Document> list = simpleService.getDocs();
		
		List<Long> idList = simpleService.reIndex(list);
		
		if(null != idList && idList.size() > 0){
			simpleService.updateDatas(idList);
		}
		long e = System.currentTimeMillis();
		log.info("End simple work. Spends %dms",e-s);
	}
	
	private static Logger log = new Logger();
	private SimpleService simpleService;
	public void setSimpleService(SimpleService simpleService) {
		this.simpleService = simpleService;
	}
}
